home *** CD-ROM | disk | FTP | other *** search
/ CD School House 9 / CD School House 9.0 - Wayzata Technology (1994).iso / pc / dos / math / mafia2a / odesolve.hlp < prev    next >
Text File  |  1992-10-01  |  13KB  |  320 lines

  1.   ╔══════════════════════════════╗                (C) Copyright 1986-1990
  2.   ║  WELCOME to the ODE Solver ! ║                      Zvi Shippony
  3.   ╚══════════════════════════════╝                     (818) 990-0134
  4.  
  5.     This Program solves Ordinary Differential Equations. The main use is
  6.  solving Initial Condition (I.C) type problems but for second order equation
  7.  the user have the option to solve a Two-Point-Boundary Value problem (B.V).
  8.  
  9.  Option #1:
  10.  ----------
  11.     Solves a set of N First order ODE whose Right-Hand-Side (RHS) is any
  12.  legal expression of the form: F(X,Y0,Y1,Y2,...,Y9)   (Thus N <= 10 ).
  13.  
  14.  Option #2:
  15.  ----------
  16.     Solves an N-th order ODE whose RHS is any legal expression of the form:
  17.  F(X,Y,Y',Y'',Y''',..,Y''''''''')  or F(X,Y0,Y1,Y2,Y3,..,Y9)  where Y0 stands
  18.  for Y, Y1 stands for Y', Y2 stands for Y'' and so on. YOU CAN USE BOTH
  19.  NOTATIONS.
  20. $$$
  21.  
  22.  'Expression' is any legal combination of: +, -, *, /, **, (, ), AND any of
  23.   the following functions:
  24.  
  25.    ABS, INT, EXP, SIN, COS, TAN, COT, LOG, LN, FACT or ! (Factorial)
  26.    SQRT, SINH, COSH, TANH, ARCSIN, ARCCOS, ARCTAN, ARCSINH, ARCCOSH, ARCTANH
  27.  
  28.    And the "Special Functions" :
  29.  
  30.      Z(x)     { Riemann's Zeta function }
  31.      G(x)     { Gamma function, (IF x is an integer then x! = G(x+1)) }
  32.      BJ(n,x)  { Bessel Function of the  first kind, J(n,x) }
  33.      BY(n,x)  { Bessel Function of the second kind, Y(n,x) }
  34.      BI(n,x)  { Modified Bessel Function of the  first kind, I(n,x) }
  35.      BK(n,x)  { Modified Bessel Function of the second kind, K(n,x) }
  36.      SBJ(n,x) { Spherical Bessel Function of the  first kind, j(n,x) }
  37.      SBY(n,x) { Spherical Bessel Function of the second kind, y(n,x) }
  38.  
  39.   PI is a reserved name and will be interpeted as Pi = 3.14159265358....
  40.  
  41. $$$
  42.     Interval of solution (A,B) is needed, where A  and/or B  are either given
  43.  as numbers or any expression containing numbers. A comma is required between
  44.  A and B .
  45.  
  46.     For example: if A = 0.0 and B = Pi/4.0, the input could be given as:
  47.        0.0 , pi/4   or:  0.0 , arctan(1.0)   .
  48.  
  49.     Initial Conditions (or Boundary Values) could be given as numbers or any
  50.  legal expression containing numbers .
  51.  
  52.  NOTE ON TWO-POINT-BOUNDARY-VALUE PROBLEMS: (Applies for 2-nd order eqn. only)
  53.  -----------------------------------------------------------------------------
  54.     Only explicit boundary values are accepted. That is, boundary  value can
  55.  not be a function of Y itself.
  56.    ( Right example: Y(1.0)=5*exp(1)    Wrong example: Y(1.0)=5*Y(0.0)  )
  57.  
  58.     The method for solving boundary value problem is a combination of FINITE-
  59.  DIFFERENCE Method and the SHOOTING Method.  The user can supply the program
  60.  with the partial derivatives of F(X,Y,Y') w.r.t.  Y and Y', this way the
  61.  convergence will be faster (using Newton's Method) but if these are not
  62.  supplied, the iterations will be done with the False-Position Method, which
  63.  gives slower convergence (and the FINITE-DIFFERENCE step will NOT be used).
  64. $$$
  65.   Accuracy of solution:
  66.   ---------------------
  67.     The program will try to achieve the inputted accuracy, but the higher
  68.  the requested accurate is,  the longer the execution time will be. Some time
  69.  roundoff errors will stop the execution without achieving the desired
  70.  accuracy. The smallest possible accuracy is: 5.0E-14 (default).
  71.  
  72.     The method used for all I.C. problems is the Bulirsch_Stoer integration
  73.  procedure with 4-th order Runge-Kutta step taken at points of non-convergence.
  74.  
  75.     When the program writes: '** Finished' , the solution is stored in an
  76.  array of up to 100 entries equally spaced.
  77.  
  78.     The user has the option to ask for any specific X-value (as long as this
  79.  value is in the interval [A,B] ) and the program will interpolate for that
  80.  value.
  81.  
  82.     Another way is to store these entries in a file for later use (Plotting,
  83.  Printing,  etc.)
  84. $$$
  85.  
  86.  Option #3:  Loading a system from a file
  87.  ----------
  88.     Any ASCII file written in the format bellow could be used to load a pre-
  89.  determined system into the program for solving. The file MUST have that
  90.  format in order to work properly. It could be written in any editing type
  91.  S/W (like: Edlin, WordStar, Word-Perfect, Word  etc..). Each line has a colon
  92.  (':') separating between the name of the input and its value.
  93.  
  94.  Note: You can insert comments anywhere in the line as { ... }.
  95.  
  96.  
  97.  There are 2 slightly different file formats, according to the option needed:
  98. $$$
  99.  
  100.          File format for option 1 (System of N first order equations):
  101.          -------------------------------------------------------------
  102.  
  103. Option  : 1
  104. Order   : {1 to 10}
  105. Type    : IC
  106. Domain  : {X-Range in the format: x1 , x2}  (Don't forget the comma !!)
  107. Accuracy: {Integration accuracy to use}
  108. StepSize: {Step size to use}
  109. Eqn. #0 : {The Right-hand-size expression to use for Y0'}
  110. Eqn. #1 : {The Right-hand-size expression to use for Y1'}
  111. Eqn. #2 : {The Right-hand-size expression to use for Y2'}
  112.    .                    .
  113.    .                    .
  114. Eqn. #n :     {Where n is = order -1 }
  115. Initial condition Y0(LHS): {Y  value at the initial point}
  116. Initial condition Y1(LHS): {Y' value at the initial point}
  117.    .                                    .
  118.    .                                    .
  119. Initial condition Yn(LHS):     {Where n is = order-1}
  120.  
  121. $$$
  122.                 File format for option 2 (N-th order equation):
  123.                 -----------------------------------------------
  124.  
  125. Option  : 2
  126. Order   : {1 to 10}
  127. Type    : {IC or BV}
  128. Domain  : {X-Range in the format: x1 , x2}  (Don't forget the comma !!)
  129. Accuracy: {Integration accuracy to use}
  130. StepSize: {Step size to use}
  131. Equation: {The Right-hand-size expression to use}
  132. dF/dY   : {FOR BV PROBLEMS ONLY, the derivative of F(X,Y,Y') w.r.t  Y }
  133. dF/dY'  : {FOR BV PROBLEMS ONLY, the derivative of F(X,Y,Y') w.r.t  Y'}
  134. Boundary Value Y0(LHS) : {The Left-Hand_Side Y value }
  135. Boundary Value Y0(RHS) : {The Right-Hand-Side Y value}
  136.        or:
  137. Initial condition Y0(LHS): {Y  value at the initial point}
  138. Initial condition Y1(LHS): {Y' value at the initial point}
  139.           .                              .
  140.           .                              .
  141. Initial condition Yn(LHS):     {Where n is the order-1}
  142. $$$
  143.  
  144. NOTE:
  145.  
  146.     Some times the equation (the 7-th input) is too long to fit on one line.
  147.  In this case you can continue it on the next line by starting it with
  148.  a colon (':') and then type in the rest of the equation, i.e. :
  149.  
  150. Equation: (1 + sin(y') - cos(y''*y''') + tan(y''''*y''''') -
  151.  : y''*y'''') / sqrt(y''**2 + y'''**2)
  152.  
  153.  
  154.   YOU CAN USE AS MANY CONTINUATIONS YOU WANT,BUT AFTER SQUEEZING ALL THE
  155.   EXPRESSION(s) FROM BLANKS AND CONVERTING ALL THE PRIME NOTATIONS
  156.   (Y',Y'',Y''',...) INTO (Y1,Y2,Y3,..) THE FINAL EQUATION CAN NOT BE LONGER
  157.   THEN 76 CHARACTERS !!
  158.  
  159. $$$
  160.  
  161.  Option #4:  Storing a system into a file
  162.  ----------
  163.     After a system has been solved, you can store it into a file. The program
  164.  will write an ASCII file in the format given in the above example. This file
  165.  can be then edited and used later as loading file (as in option 3 above)
  166.  
  167. $$$
  168.  
  169.  
  170.  
  171.  
  172.  WE ARE GOING TO WALK THROUGH 2 COMPLETE EXAMPLES NOW ..
  173.  
  174. $$$
  175.  
  176.   Example #1:    After the program is loaded, it starts like:
  177.   -----------
  178.  
  179.   Your options are:
  180.  
  181.   1 - Solve system of N first order O.D.E.: Yi' = F(X,Yj) (i,j = 0,1,..,N-1)
  182.   2 - Solve N-th order O.D.E., e.g: Y''' = F(X,Y0,Y1,Y2)
  183.       Where: Y0 ≡ Y, Y1 ≡ Y', Y2 ≡ Y''   (You can use either notation..)
  184.   3 - Load a system from a file
  185.   4 - Store last system on file
  186.   M - Memory manipulations
  187.   B - Set Bell  ON / OFF  for error or info. msg. Bell is now: OFF
  188.   H - Help and information about the program
  189.     - Any other key to quit ..
  190.  
  191.   Enter your Choice (1 - 4, M, B, H or Quit):
  192.  
  193.  ( LET US CHOOSE 2nd-ORDER  2-POINTS BOUNDARY-VALUE PROBLEM: Y''= -(2*Y'+Y)
  194.    Solution: Y(x)=X*EXP(-X) , FOR X=[-1,4], Y(-1)=-EXP(1), Y(4)=4*EXP(-4) )
  195.  
  196.   Enter your Choice (1, 2, 3, B, H or Quit): 2
  197.   Store various inputs in Memory ? (y/n): n   (SAY: N)
  198.   Enter order of ODE (1-10): 2
  199. $$$
  200.    Enter: IC for Initial Condition Problem
  201.    Enter: BV for Two-Point-Boundary Value Problem
  202.           Your choice: BV
  203.  
  204.  (THE PROGRAM WILL NOW PRESENTS YOU WITH THE LINE: Y'' =
  205.   THIS IS THE TIME TO ENTER THE EQUATION(S) ...)
  206.  
  207.   Y'' = -(2*y'+y)        ( SO F(X,Y,Y') = -2*Y'-Y )
  208.  (YOU COULD ALSO ENTER: -(2*Y1+Y0)  or: -(2*Y'+Y0) etc ..)
  209.  
  210. ** For faster convergence we need dF/dY and dF/dY'
  211.    Are you supplying those ? (y/n): y               (SAY: Y)
  212.  
  213.   dF/dY  = -1                   (THIS IS DF/DY )
  214.   dF/dY' = -2                   (THIS IS DF/DY')
  215.  
  216.   Enter x Domain ( e.g.:  -1.0 , 1.0): -1,4
  217.   Enter desired accuracy (Default is: 5.0E-14): 1.e-10
  218.   Compute solution every what Delta-x ? 0.05           (Total of 100 points)
  219.  
  220.   Enter B.V:  Y(-1.0) (Default: 0.0): -exp(1)
  221.   Enter B.V:  Y(4.0) (Default: 0.0): 4*exp(-4)
  222.   ** Do you wish to stop (pause) after each iteration ? (y/n): n  (SAY: N )
  223.  ( YOU HAVE THE OPTION TO CONTROL THE ITERATIONS PROCESS )
  224. $$$
  225.  ( SINCE WE CHOSE 2-POINT BOUNDARY-VALUE PROBLEM, THE FIRST METHOD IS THE
  226.    FINIT-DIFFERENCE METHOD ..THE PROGRAM WILL SAY:)
  227.  
  228. ** Iterative Finite-Difference Method  **
  229.    # of iterations:   2 Yields: dy/dx(LHS) =  5.43638706110044E+000
  230.    Number of mesh points: 100  Step size: 4.95050E-002
  231.    Solution accuracy at mesh points: Order(2.0E-3)
  232.  
  233.    Are you satisfied with the current accuracy ? (y/n) n     (SAY: N )
  234.  
  235.    Start Shooting Method now with the above guess for dy/dx(LHS)
  236.  
  237.                                 ( Working ... )
  238. $$$
  239.  
  240. ** Iterative Shooting Method  **
  241.    Given B.V:  7.32625555549367E-002  Achieved B.V:  7.32625555469740E-002
  242.    Rel. Error: 7.96270E-012   Using dy/dx(LHS) =  5.43656365665446E+000
  243.    Integration accuracy: 1.00000E-010  Max. step size used: 5.00000E-002
  244.    Next guess for dy/dx(LHS)  is:  5.43656365668701E+000
  245.  
  246.                                 ( Working ... )
  247.  
  248.   *** Finished ...        (HOORAY ! IT CONVERGED ...)
  249.  
  250.   To Plot or do Least-Square-Fit of the solution we need to write the results
  251.   into a file.  Write a file ? (y/n):    (SAY: Y)
  252.   Enter file name: ODETST
  253.  
  254. First title for the file is: SOLUTION OF: Y'' = -(2*Y1+Y0)
  255. Enter (optional) 2-nd title (Initial or Boundary conditions, remarks, etc ..)
  256. Title:Testing. BV: y(-1)=-exp(1), y(4)=4*exp(-4)  eps=1.0e-10
  257. (THE PROGRAM WILL RESPOND BY:) ** File: ODETST is ready .
  258. $$$
  259.   Example #2:
  260.   -----------
  261.   Your options are:
  262.  
  263.   1 - Solve system of N first order O.D.E.: Yi' = F(X,Yj) (i,j = 0,1,..,N-1)
  264.   2 - Solve N-th order O.D.E., e.g: Y''' = F(X,Y0,Y1,Y2)
  265.       Where: Y0 ≡ Y, Y1 ≡ Y', Y2 ≡ Y''   (You can use either notation..)
  266.   3 - Load a system from a file
  267.   4 - Store last system on file
  268.   M - Memory manipulations
  269.   B - Set Bell  ON / OFF  for error or info. msg. Bell is now: OFF
  270.   H - Help and information about the program
  271.     - Any other key to quit ..
  272.  
  273.   Enter your Choice (1 - 4, M, B, H or Quit):
  274.  ( LET US CHOOSE SYSTEM OF TWO 1-st ORDER EQUATIONS)
  275.  
  276.   Enter your Choice (1, 2, 3, B, H or Quit): 1
  277.   Store various inputs in Memory ? (y/n): n   (SAY: N)
  278.   Enter number of equations (1-10): 2
  279.  
  280.   Y0' = Y1
  281.   Y1' = -Y0      ( The solution is: Y0(X)=SIN(X), Y1(X)=COS(X)  )
  282. $$$
  283.  
  284.   Enter x Domain ( e.g.:  -1.0 , 1.0): -PI,PI
  285.   Enter desired accuracy (Default is: 5.0E-14): 1.E-8
  286.   Compute solution every what Delta-x ? 0.1
  287.  
  288.   Enter I.C:  Y0(-3.14159265358979) (Default: 0.0): 0.0
  289.   Enter I.C:  Y1(-3.14159265358979) (Default: 0.0): -1.0
  290.  
  291.                                 ( Working ... )
  292.  
  293.   *** Finished ...
  294.  
  295.   To Plot or do Least-Square-Fit of the solution we need to write the results
  296.   into a file.  Write a file ? (y/n):    (SAY: N)
  297.        ( WE ARE SKIPPING THE FILE WRITING OPTION .. )
  298. $$$
  299. ( THE PROGRAM WILL SAY:)
  300.  
  301.   For what x you want y(x) ? (Hit Enter to stop) 1.1    (ENTER: 1.1 )
  302.  
  303. ( THE PROGRAM WILL INTERPOLATE THE SOLUTION FOR X = 1.1 )
  304.  
  305.  x:   1.10000000000000E+000 y0:   8.91207360381939E-001
  306.                             y1:   4.53596121602802E-001
  307.  
  308. ( CHECK IT OUT, THE TRUE SOLUTION IS:
  309.  
  310.    SIN(1.1) = 8.91207360061435E-001   SO THE ERROR IS:  3.21e-11
  311.    COS(1.1) = 4.53596121425577E-001   SO THE ERROR IS:  1.77e-11  )
  312.  
  313. ( THE PROGRAM WILL CONTINUE TO ASK FOR WHAT X TO INTERPOLATE, HIT ENTER TO
  314.   QUIT ..)
  315.  
  316. ( THE PROGRAM WILL GIVE YOU ONE MORE CHANCE TO WRITE THE SOLUTION INTO A FILE
  317.   AS DESCRIBED IN EXAMPLE #1 ABOVE ..)
  318.  
  319.                             That's all folks ...
  320.